/**
 * There are <a href="https://www.hdzhx.com">邯郸智讯</a> code generation
 */
package com.boxin.ims.modules.wechat.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.validator.constraints.Length;

import com.thinkgem.jeesite.common.persistence.BaseEntity;
import com.thinkgem.jeesite.modules.sys.entity.User;

/**
 * 微信48小时信息Entity
 * @author XiaoQian
 * @version 2014-05-08
 */
@Entity
@Table(name = "wp_wechat_message_near")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class WechatMessageNear extends BaseEntity {
	
	private static final long serialVersionUID = 1L;
	private Long id; 				// 编号
	private User user; 				// 用户
	private String wpId;			//微信ID
	private String message;			//即时信息
	private String messageType;		//消息类型
	private String eventType;		//事件类型
	private Date createTime;		//消息发送时间
	private String day ;			//日期 格式如：20140323
	private String month;			//日期：月   201403
	private String year;			//日期：年  2014

	public WechatMessageNear() {
		this.createTime = new Date();
	}

	public WechatMessageNear(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@ManyToOne
	@JoinColumn(name="user_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getWpId() {
		return wpId;
	}
	public void setWpId(String wpId) {
		this.wpId = wpId;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public String getMessageType() {
		return messageType;
	}
	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}
	public String getEventType() {
		return eventType;
	}
	public void setEventType(String eventType) {
		this.eventType = eventType;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getDay() {
		return day;
	}

	public void setDay(String day) {
		this.day = day;
	}

	public String getMonth() {
		return month;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}
	
	public static WechatMessageNear parse(WechatMessage wechatMessage){
		WechatMessageNear wechatMessageNear=new WechatMessageNear();
		wechatMessageNear.setUser(wechatMessage.getUser());
		wechatMessageNear.setWpId(wechatMessage.getWpId());
		wechatMessageNear.setDay(wechatMessage.getDay());
		wechatMessageNear.setEventType(wechatMessage.getEventType());
		wechatMessageNear.setMessage(wechatMessage.getMessage());
		wechatMessageNear.setMessageType(wechatMessage.getMessageType());
		wechatMessageNear.setMonth(wechatMessage.getMonth());
		wechatMessageNear.setYear(wechatMessage.getYear());
		return wechatMessageNear;
	}
	
}


